# -*- coding: utf-8 -*-
# standard
import os
import sys

# third

# local
_P_PATH = os.path.dirname(os.path.realpath(__file__))
if _P_PATH not in sys.path:
    sys.path.append(_P_PATH)
from models.copy_models import *


"""
@Title:   
@File: 修复gup上错误的命名.py
@Author: walle 2023年11日03日 15时44分35秒
@Version: 1.0.0
@Desc: 
"""



def move_gpu_videos():
    host = "gpu1.welltop.tech"
    user = "root"
    password = "Default01!"
    src_dir = "/mnt/aiface/data/i2v/"
    dst_dir = "/mnt/aiface/data/i2v/work_data/"
    src_files = view_remote_files(dir_path=src_dir, host=host, user=user, password=password)[0]
    src_files = [x for x in src_files if x.endswith(".mp4")]
    src_files

    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())  
    # 连接到远程Linux系统  
    ssh.connect(hostname=host, port=22, username=user, password=password)    
    # 执行命令并获取输出  
    for file_name in src_files:
        src = f"{src_dir}{file_name}"
        dst = f"{dst_dir}{file_name[9:]}"
        command = f'mv {src} {dst}'
        stdin, stdout, stderr = ssh.exec_command(command)  
        output = stdout.read().decode()  
        # 打印输出结果  
        print(output)  
        if output == "":
            print(f"{file_name} 已移动")
    # 关闭SSH连接  
    ssh.close()
    print("工作结束")


if __name__ == '__main__':
    move_gpu_videos()
    pass